/*
--------------------------------------------------------------------------------
				Ak-Lib. 
			 Project       	: Ak-Lib
			 Group         	: Ak-Lib R&D Team
			 Author        	: Ocean.Wang
			 Create Date 	: 05-01-2010
--------------------------------------------------------------------------------
Code Name 	:  A.K 	~v~
Description	:  Yet Another Cross-Platform Lib.
Cautions    	:
--------------------------------------------------------------------------------
Change History:
Version		: 0.1
Building 		: 05/01/10
10-05.01 first draft, build, debug and test.
--------------------------------------------------------------------------------
*/

#include "ak_log.h"
#include "ak_gears.h"

static 	_t_log_task 		_gLogTask;

static 	int 	_LogTest_Std(void)
{
	int 	i, count;
	char 	buf[0X100];

	SLog_Init(&_gLogTask);
	SLog_SetBkEnd(SLOG_TASK_CTRL_N(&_gLogTask, 0),
					_S_LOG_BKEND_STD,
					NULL,
					0X7F000001,
					_S_LOG_SVR_PORT);	

	SLog_SetBkEnd(SLOG_TASK_CTRL_N(&_gLogTask, 1),
					_S_LOG_BKEND_FILE,
					"/tmp/",
					0X7F000001,
					_S_LOG_SVR_PORT);	

	SLog_Exec(&_gLogTask);

	for(i=0; i<0X100; i++){
		buf[i]=i;
	}
	i = 0;
	do{
		SYS_SLEEP(2000);
		count = 0X04;
		do{
			SLogging(SLOG_TASK_CTRL_N(&_gLogTask, 0), _S_LOG_T_ASCII,
					__FUNCTION__,
					__LINE__,
					"Test Ascii ", 	11,
					"Test", 		4);
			SLogging(SLOG_TASK_CTRL_N(&_gLogTask, 1), _S_LOG_T_BINARY,
					__FUNCTION__,
					__LINE__,
					"Test Binary", 	11,
					buf, 			0X100);
		}while(--count);
		
	}while(1);
	
	return 0;
}


static 	int 	_LogTest_Mon(void)
{
	int 			i, count;
	char 			buf[0X100];

	SLog_Init(&_gLogTask);
	SLog_SetBkEnd(SLOG_TASK_CTRL_N(&_gLogTask, 0),
					_S_LOG_BKEND_FILE,
					"/tmp/",
					0X7F000001,
					_S_LOG_SVR_PORT);	

	SLog_Exec(&_gLogTask);

	for(i=0; i<0X100; i++){
		buf[i]=i;
	}
	STrace_HexDump((unsigned char *)buf, 0X100);
	
	i = 0;
	do{
		SYS_SLEEP(1000);
		count = 0X50;
		do{
			SLogging(SLOG_TASK_CTRL_N(&_gLogTask, 0), _S_LOG_T_MFILE,
					NULL,	0,
					NULL, 	0,
					buf, 	0X100);
		}while(--count);
		
	}while(1);
	
	return 0;
}


static 	int 	_LogTest_MonShow(void)
{
	int 		i;
	_t_log_mon 	logMan;
	
	SMon_Init(&logMan, "/tmp/");
	for(i=0; i<100; i++){
		SMon_Show(&logMan, i*1911, NULL, 0);
	}
	return 0;
}

int 	main(void)
{

	_LogTest_MonShow();
	return 0;
}
